<%@page import="com.bci.pwtz.common.PWTZJspWriter"%>
<%@page import="com.bci.pwtz.controller.AbstractController"%>
<%@page import="com.bci.pwtz.service.CompanyUserService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.bci.pwtz.mysql.model.CompanyUser"%>
<%@ page import="com.bci.pwtz.common.util.CookieUtil" %>
<%@ page import="com.bci.pwtz.common.util.SpringUtil" %>
<%@ page import="com.bci.pwtz.common.ActionCodeConstants" %>
<%@page import="com.bci.pwtz.service.CompanyRoleService"%>
<%@page import="com.bci.pwtz.exception.PwtzDatabaseException"%>
<META http-equiv="X-UA-Compatible" content="IE=9" ></META>
<%	
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
	CompanyUser user = (CompanyUser) session.getAttribute("user");
	CompanyRoleService commonCompanyRoleService = (CompanyRoleService)SpringUtil.getBean("companyRoleService");
	CompanyUserService userService = (CompanyUserService)SpringUtil.getBean("companyUserService");
	Long userId=null;
	if(user==null){
	    CookieUtil util=new CookieUtil();
		String plam[]=util.getCookieAccount(request);
		String cooktel=plam[0];
		String cookiepwd=plam[1];
		System.out.println("cooktel="+cooktel+"|"+cookiepwd);
		if(cooktel!=null && cookiepwd!=null)//aoto logo..
		{
		    user = userService.findUserInfo(cooktel, cookiepwd);
		    if (null != user)
            {
                userId = user.getCompanyUserId();
                session.setAttribute("user", user);
                session.setAttribute("userId", userId);
                List<String> actionList=new ArrayList<String>();
                Long currentUserId=((CompanyUser) session.getAttribute("user")).getCompanyUserId();
                Long currentCompanyId=((CompanyUser) session.getAttribute("user")).getLastCompanyId();
                try
                {
                    actionList=commonCompanyRoleService.selectRoleAction(currentCompanyId, currentUserId);
                }
                catch (PwtzDatabaseException e)
                {
                    e.printStackTrace();
                }
                session.setAttribute("actionList", actionList);
            }
		}
	}else{
	    userId=user.getCompanyUserId();
	}
	/*
	
	CompanyUserServiceImpl userService = (CompanyUserServiceImpl)SpringUtil.getBean("companyUserService");
    user = userService.findUserInfo("15208323973", "c870366df3a80247095d97b6fb316ef8e8116f54f94905bd8f44e2fbfe4a002a");
    if (null != user)
    {
        Long userId = user.getCompanyUserId();
        session.setAttribute("user", user);
        session.setAttribute("userId", userId);
    }
    */
	out = new PWTZJspWriter(out);
    List<String> actionList=(List<String>)session.getAttribute("actionList");
    boolean mediumqueryaction=AbstractController.isHasAction("medium_data_query", actionList);
    boolean mediumaddaction=AbstractController.isHasAction("medium_data_add", actionList);
    boolean mediumeditaction=AbstractController.isHasAction("medium_data_edit", actionList);
    boolean mediumdeleteaction=AbstractController.isHasAction("medium_data_delete", actionList);
    boolean cadqueryaction=AbstractController.isHasAction("cad_stat_query", actionList);
    boolean lowqueryaction=AbstractController.isHasAction("low_data_query", actionList);
    boolean lowaddaction=AbstractController.isHasAction("low_data_add", actionList);
    boolean loweditaction=AbstractController.isHasAction("low_data_edit", actionList);
    boolean lowdeleteaction=AbstractController.isHasAction("low_data_delete", actionList);
    boolean messageauditaction=AbstractController.isHasAction("audit_message_manage", actionList);
    boolean companyqueryaction=AbstractController.isHasAction("company_query", actionList);
    boolean companyaddaction=AbstractController.isHasAction("company_add", actionList);
    boolean companyeditaction=AbstractController.isHasAction("company_edit", actionList);
    boolean companydisableaction=AbstractController.isHasAction("company_edit_disable", actionList);
    boolean companyenableaction=AbstractController.isHasAction("company_edit_enable", actionList);
    boolean userqueryaction=AbstractController.isHasAction("user_query", actionList);
    boolean useraddaction=AbstractController.isHasAction("user_add", actionList);
    boolean usereditaction=AbstractController.isHasAction("user_edit", actionList);
    boolean userdeleteaction=AbstractController.isHasAction("user_delete", actionList);
    boolean rolequeryaction=AbstractController.isHasAction("role_query", actionList);
    boolean roleaddaction=AbstractController.isHasAction("role_query", actionList);
    boolean roleeditaction=AbstractController.isHasAction("role_edit", actionList);
    boolean roledeleteaction=AbstractController.isHasAction("role_delete", actionList);
    boolean operatelogqueryaction=AbstractController.isHasAction("operate_log_query", actionList);
    boolean dataimportexportaction=AbstractController.isHasAction("data_import_export_add", actionList);
    boolean datastatqueryaction=AbstractController.isHasAction("data_stat_query", actionList);
    boolean devicestatquery=AbstractController.isHasAction("device_stat_query", actionList);
    boolean userstatquery=AbstractController.isHasAction("user_stat_query", actionList);
	boolean isSuper=Boolean.parseBoolean(session.getAttribute("isSuper")+"");
%>
<script type="text/javascript">
//<!--
//var contextPath = "${ctx}";
var contextPath = "${pageContext.request.contextPath}/";
var cookiePath = "<%=path%>";
var basePath = "<%=basePath%>";
var mediumaddaction =<%=mediumaddaction%>;
var mediumeditaction =<%=mediumeditaction%>;
var mediumdeleteaction =<%=mediumdeleteaction%>;
var mediumqueryaction = <%=mediumqueryaction%>;
var lowaddaction =<%=lowaddaction%>;
var loweditaction =<%=loweditaction%>;
var lowdeleteaction =<%=lowdeleteaction%>;
var lowqueryaction = <%=lowqueryaction%>;
var cadqueryaction = <%=cadqueryaction%>;
var isSuper=<%=isSuper%>;
//-->
</script>